package com.example.util;

import java.net.Inet4Address;
import java.net.InetAddress;
import java.net.UnknownHostException;

public class NetWorkUtil {
    public static boolean isAvailable(String address) {

        InetAddress byName = null;
        try {
            byName = InetAddress.getByName(address);
        } catch (UnknownHostException e) {
            return false;
        }
        if (!(byName instanceof Inet4Address)) {
            return false;
        }
        try {
            return byName.isReachable(1000);
        } catch (Exception e) {
            return false;
        }


    }
}
